//
//  PPUserViewCell.m
//  PropertyManage
//
//  Created by Dreamsoul on 15-3-24.
//  Copyright (c) 2015年 com.lab603.mc. All rights reserved.
//

#import "PPUserViewCell.h"
#import "PPUserCellFrame.h"
#import "PPMe.h"
#import "UIImageView+WebCache.h"
@interface PPUserViewCell()
@property (nonatomic,weak)UIImageView *backgrundView;
@property (nonatomic,weak)UIImageView *iconView;
@property (nonatomic,weak)UILabel *nameLabel;
@property (nonatomic,weak)UILabel *editLabel;
@end
@implementation PPUserViewCell
+ (instancetype)cellWithTabelView:(UITableView *)tableView{
    static NSString *ID = @"userCell";
    PPUserViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell==nil) {
        cell = [[PPUserViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
    }
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectedBackgroundView = [[UIView alloc] init];
        //设置背景图片
        UIImageView *backgroundView = [[UIImageView alloc] init];
        backgroundView.image = [UIImage resizedImageWithName:@"timeline_card_top_background"];
        backgroundView.highlightedImage = [UIImage resizedImageWithName: @"timeline_card_top_background_highlighted"
                                           ];
        [self.contentView addSubview:backgroundView];
        self.backgroundView = backgroundView;
        
        //设置头像图片
        UIImageView *iconView = [[UIImageView alloc] init];
        [self.backgroundView addSubview:iconView];
        self.iconView = iconView;
        
        //设置用户名
        UILabel *nameLabel = [[UILabel alloc] init];
        [nameLabel setBackgroundColor:[UIColor clearColor]];
        [nameLabel setTextColor:[UIColor blackColor]];
        nameLabel.numberOfLines = 0;
        nameLabel.font = [UIFont systemFontOfSize:14.0];
        [self.backgroundView addSubview:nameLabel];
        self.nameLabel = nameLabel;
        
        //设置修改个人信息字段
        UILabel *editLabel = [[UILabel alloc] init];
        [editLabel setBackgroundColor:[UIColor clearColor]];
        [editLabel setTextColor:APP_THEME_COLOR];
        editLabel.numberOfLines = 0;
        editLabel.font = [UIFont systemFontOfSize:14.0];
        [self.backgroundView addSubview:editLabel];
        self.editLabel = editLabel;
    }
    return self;
}
- (void)setUsercellFrame:(PPUserCellFrame *)usercellFrame{
    _usercellFrame = usercellFrame;
    //设置frame
    self.backgrundView.frame = usercellFrame.backgroundViewF;
    self.iconView.frame = usercellFrame.iconF;
    self.nameLabel.frame = usercellFrame.typeF;
    self.editLabel.frame = usercellFrame.editF;
    //设置数据
    PPMe *me = usercellFrame.me;
    NSString *iconString = [NSString stringWithFormat:@"%@%@",StaticFileUrl,me.icon];
    [self.iconView sd_setImageWithURL:[NSURL URLWithString: iconString] placeholderImage:[UIImage imageWithName:@"meIcon.png"]];

    self.nameLabel.text = me.typeString;
    self.editLabel.text = @"编辑个人信息";
}
@end
